package com.wanxi.controller;

import com.wanxi.dto.ProductDTO;
import com.wanxi.dto.ProductDetailDTO;
import com.wanxi.model.ProductQuery;
import com.wanxi.result.CommonResult;
import com.wanxi.service.FrontProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "服务包相关接口")
@RestController
@RequestMapping("/front/product")
public class FrontProductController {

    @Autowired
    private FrontProductService frontProductService;

    @ApiOperation(value = "查询服务包")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK", response = ProductDTO.class, responseContainer = "List")
    })
    @GetMapping("/findProduct")
    public CommonResult findProduct(ProductQuery productQuery) {
        return frontProductService.findProduct(productQuery);
    }

    @ApiOperation(value = "查询服务包详情")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK", response = ProductDetailDTO.class)
    })
    @GetMapping("/findProductDetail")
    public CommonResult findProductDetail(Long productId) {
        return frontProductService.findProductDetail(productId);
    }

}
